#!/bin/sh
# PCP QA Test No. 1525 (SGI test 1013 and formerly 213)
# Check generation of pmview config files of pmview front-ends.
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved..
# Copyright (c) 2024 Ken McDonell.  All Rights Reserved.
#

if [ $# -eq 0 ]
then
    seq=`basename $0`
    echo "QA output created by $seq"
else
    # use $seq from caller, unless not set
    [ -n "$seq" ] || seq=`basename $0`
    echo "QA output created by `basename $0` $*"
fi

# get standard Qt environment, filters and checks
. ./common.qt


which dkvis >/dev/null 2>&1 || _notrun "No dkvis binary installed"
which mpvis >/dev/null 2>&1 || _notrun "No mpvis binary installed"
which nfsvis >/dev/null 2>&1 || _notrun "No nfsvis binary installed"
which osvis >/dev/null 2>&1 || _notrun "No osvis binary installed"
which pmview >/dev/null 2>&1 || _notrun "No pmview binary installed"

status=0	# success is the default!
trap "_cleanup_qt; exit \$status" 0 1 2 3 15

# $tmp.ctrls line is pending a TODO fix for osvis and strange
# error messages on vm11
#
_filter()
{
    _filter_qt \
    | sed \
	-e "s@$tmp@TMP@g" \
	-e '/cannot open/{
s@/tmp/[0-9][0-9]*.ctrls@TMP.ctrls@
s@1: /usr/bin/osvis:@1:@
}' \
    # end
}

# real QA test starts here
PCP_STDERR=$tmp.err

archive=archives/babylon.pmview_v2
for tool in dkvis mpvis nfsvis
do
    rm -f $tmp.err
    echo "--- $tool -a $archive ... --"
    $tool -a $archive -C -C -V 2>&1 \
    | _filter
    if [ -s $tmp.err ]
    then
	echo "+++ stderr"
	_filter <$tmp.err
    fi
done

archive=archives/20180415.09.16
for tool in osvis
do
    rm -f $tmp.err
    echo "--- $tool -a $archive ... --"
    $tool -a $archive -C -C -V 2>&1 \
    | _filter
    if [ -s $tmp.err ]
    then
	echo "+++ stderr"
	_filter <$tmp.err
    fi
done

# all done
exit
